package com.usian.comment.controller;

import com.usian.comment.ApCommentControllerApi;
import com.usian.comment.service.ApCommentService;
import com.usian.model.comment.dtos.CommentDto;
import com.usian.model.comment.dtos.CommentLikeDto;
import com.usian.model.comment.dtos.CommentSaveDto;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class ApComentController implements ApCommentControllerApi {


    @Autowired
    private ApCommentService apCommentService;


    /**
     * 用户文章发布评论
     *
     * @param dto
     * @return
     */
    @Override
    @RequestMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto) {
        return apCommentService.saveComment(dto);
    }

    /**
     * 评论点赞、取消点赞
     *
     * @param dto
     * @return
     */
    @Override
    @RequestMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return apCommentService.saveCommentLike(dto);
    }

    /**
     * 查询文章评论列表
     *
     * @param dto
     * @return
     */
    @Override
    @RequestMapping("/load")
    public ResponseResult findByArticleId(@RequestBody CommentDto dto) {
        return apCommentService.findByArticleId(dto);
    }
}
